package calorie.com.calorie.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lxh.baselibray.util.TimeUtils;

import java.text.SimpleDateFormat;
import java.util.List;

import calorie.com.calorie.R;
import calorie.com.calorie.response.InviteFriendResponce;
import calorie.com.calorie.response.User;
import calorie.com.calorie.util.StaticValue;

/**
 * Created with IntelliJ IDEA.
 * User: ZhaoShiDong
 * Date: 2018/10/16
 * Time: 11:30
 */
public class MyInvitationAdapter extends BaseQuickAdapter<InviteFriendResponce.DataBean.SubordinateBean, BaseViewHolder> {

    public MyInvitationAdapter(int layoutResId, @Nullable List<InviteFriendResponce.DataBean.SubordinateBean> recordBeanList) {
        super(layoutResId, recordBeanList);
    }

    @Override
    protected void convert(BaseViewHolder helper, InviteFriendResponce.DataBean.SubordinateBean recordBean) {
        helper.getView(R.id.tv_Friend).setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {


                return false;
            }
        });

        String levelText = "";
        switch (recordBean.getLevel()) {
            case 0:
                levelText = "帐号未激活";
                break;
            case 1:
                levelText = "菜鸟";
                break;
            case 2:
                levelText = "达人";
                break;
            case 3:
                levelText = "健将";
                break;
            case 4:
                levelText = "精英";
                break;
            case 5:
                levelText = "教练";
                break;
            case 6:
                levelText = "大师";
                break;
            case 7:
                levelText = "王者";
                break;
        }

        helper.setText(R.id.tv_Friend, recordBean.getAccount())
                .setText(R.id.tv_Grade, levelText)
                .setText(R.id.tv_Status, "x"+recordBean.getSpeed()+"倍速")
                .setText(R.id.tv_Num, recordBean.getCommunity())
                .setText(R.id.tv_Time, recordBean.getTime()!=null? TimeUtils.millis2String(Long.parseLong(recordBean.getTime()),new SimpleDateFormat("yyyy-MM-dd")):null);
       User user = StaticValue.user;
       if(user!=null&&user.getLevel()!=null){
           if(recordBean.getLevel()==user.getLevel()||recordBean.getLevel()==0){
               helper.setTextColor(R.id.tv_Friend,mContext.getResources().getColor(R.color.gray));
               helper.setTextColor(R.id.tv_Grade,mContext.getResources().getColor(R.color.gray));
               helper.setTextColor(R.id.tv_Status,mContext.getResources().getColor(R.color.gray));
               helper.setTextColor(R.id.tv_Num,mContext.getResources().getColor(R.color.gray));
               helper.setTextColor(R.id.tv_Time,mContext.getResources().getColor(R.color.gray));
           }else{
               helper.setTextColor(R.id.tv_Friend,mContext.getResources().getColor(R.color.friend));
               helper.setTextColor(R.id.tv_Grade,mContext.getResources().getColor(R.color.friend));
               helper.setTextColor(R.id.tv_Status,mContext.getResources().getColor(R.color.yellow));
               helper.setTextColor(R.id.tv_Num,mContext.getResources().getColor(R.color.friend));
               helper.setTextColor(R.id.tv_Time,mContext.getResources().getColor(R.color.friend));
           }
       }


    }
}
